package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/bus"
	"github.com/streadway/amqp"
	"strconv"
)

//代付成功，处理出账中的消费存管金额

func main() {
	rpcFund := new(bus.Fund).Init()
	defer rpcFund.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("fund.log.consumeDeposAgentSucQueue"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("fund.queue.consumeDeposAgentSucQueue"), func(msg amqp.Delivery) {
		clearId := string(msg.Body)
		clearIdInt, _ := strconv.Atoi(clearId)
		reply := false
		err := rpcFund.DeposNeedOut( context.Background(), &clearIdInt,  &reply )
		if err != nil{
			utils.Logerr.Printf("%s id 代付成功，待出账存管消费金额任务处理失败, err:%s", clearId, err.Error())
		}
	})

	if err != nil {
		utils.Logerr.Printf("待出账存管消费金额任务处理错误，err: %s", err.Error())
	}
}

